﻿using STHPMS1.Common.C_Enum;
using STHPMS1.ICore.I_Entity.Stmpms1;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using STHPMS1.Common.C_Extension;
using STHPMS1.ICore.I_Serv;

namespace STHPMS1.BLL.B_Serv
{
    /// <summary>
    /// id 生成服务
    /// </summary>
    public class IdGenrateService : IKeyGenrateService
    {
      
        public string NewPmstcId(IB_Pmstc entity)
        {
            return entity.Struid = string.Format("JG_{0}_{1:F0}_{2}", entity.Rdwayid, entity.Beginmp,entity.Direction_Dictid);
        }

       
        public string NewSturctureId(IB_Sturcture entity)
        {
            string id = "";
            if (entity.Sttype_Dictid.IsEnumType(SturctureEnum.B111))
                id = string.Format("QL_{0}_{1:F0}_{2}", entity.Rdwayid, entity.Beginmp,entity.Direction_Dictid);
            if (entity.Sttype_Dictid.IsEnumType(SturctureEnum.T120))
                id = string.Format("SD_{0}_{1:F0}_{2}", entity.Rdwayid, entity.Beginmp, entity.Direction_Dictid);
            if (entity.Sttype_Dictid.IsEnumType(SturctureEnum.C125))
                id = string.Format("HD_{0}_{1:F0}_{2}", entity.Rdwayid, entity.Beginmp, entity.Direction_Dictid);

            return id;
        }

        public string NewRdStandard(string rdwayid, int directiontype, int changetype, double mp)
        {
            return string.Format("BZ_{0}_{1}_{2:F0}", rdwayid, changetype, mp);
        }

        public string NewInvntoryId(string rdwayid,int direct,double beginmp,double endmp)
        {
            return string.Format("LD_{0}_{1}_{2:F0}_{3:F0}", rdwayid, direct, beginmp,endmp);
        }

        public string NewInvntoryName(string rdwayname, int direct, int no)
        {
            return string.Format("{0}{1}第{2}段", rdwayname, ((DirectionEnum)direct).GetEnumDescription(), no);
        }

        public string NewUnitId(string rdwayid, int direct, double beginmp, double endmp)
        {
            return string.Format("DY_{0}_{1}_{2:F0}_{3:F0}", rdwayid, direct, beginmp, endmp);
        }

        public string NewUnitName(string rdwayname, int direct, int no)
        {
            return string.Format("{0}{1}第{2}单元", rdwayname, ((DirectionEnum)direct).GetEnumDescription(), no);
        }

        public string NewLayId(string struid, string layer_dictid)
        {
            return string.Format("{0}_{1}", struid, layer_dictid);
        }

        public string NewFwdId(IS_Rdfwd entity)
        {
            return string.Format("WC_{0}_{1:F0}_{2}", entity.Rdwayid, entity.Fwdmp,entity.Svydata.ToString("yyyyMMddHHmmsss"));
        }

        public string NewGuid()
        {
            return Guid.NewGuid().ToString();
        }


        public string NewStationId()
        {
            return string.Format("GCZ_{0}", DateTime.Now.ToString("yyyyMMdd_HHmmss_ffff"));
        }

        public string NewTrafaxleId(string rdwaryId,string segBeginmp,string direction,string aadtYear)
        {
            return string.Format("JZ_{0}_{1}_{2}_{3}", rdwaryId, segBeginmp,direction,aadtYear);
        }

        public string NewPlanId(string rdwaryId, string segBeginmp, string direction, DateTime date,int plan=0)
        {
            return string.Format("FA{0}_{1}_{2}_{3}_{4}", plan,rdwaryId, segBeginmp, direction, date.ToString("yyyyMMddHHmmsss"));
        }

        public string NewCombStruId(string iniproj_Id,string combi)
        {
            return string.Format("{0}_{1}", iniproj_Id, combi);
        }
    }
}